<template>
	<view>
	<navigator target="miniProgram" app-id='wx6007249d6b2348ea' version='release' hover-class="none">
    			<view class="dong">
    				<view class="monster">
    					<view class="monster__face">
    						<view class="monster__eye avatar-eye avatar-eye--green eye--left">
    							<view class="avatar-eye-pupil pupil--green"><span class="avatar-eye-pupil-blackThing"><span class="avatar-eye-pupil-lightReflection"></span></span></view>
    						</view>
    						<view class="monster__eye avatar-eye avatar-eye--violet eye--right">
    							<view class="avatar-eye-pupil pupil--pink"><span class="avatar-eye-pupil-blackThing"><span class="avatar-eye-pupil-lightReflection"></span></span></view>
    						</view>
    						<view class="monster__noses">
    							<view class="monster__nose"></view>
    							<view class="monster__nose"></view>
    						</view>
    						<view class="monster__mouth">
    							<view class="monster__top"></view>
    							<view class="monster__bottom"></view>
    						</view>
    					</view>
    				</view>
    			</view>
    		</navigator>
		<view class="user">
			<view class="user-top">
				<view class="userinfo" v-if="isLogin" @click="$u.route('/pagesUser/userinfo/userinfo')">
					<u-avatar mode="circle" size="150" :src="userInfo && userInfo.avatar"></u-avatar>
					<view class="info">
						<text>{{userInfo && userInfo.nickname}}</text>
						<view class="vip">
							<image src="../../static/images/VIP1.png" mode="" style="width: 40rpx;height: 40rpx;">
							</image>
							<text class="viptext">{{userVip.name}}</text>
						</view>
					</view>
				</view>
				<view class="userinfo" v-else @click="$u.route('/pages/login/login')">
					<u-avatar mode="circle" size="150" src="avatar">
					</u-avatar>
					<view class="info">
						<text style="color: #666666;">您还未登录哦</text>
					</view>
				</view>
				<view class="sigin" @click="navTo('/pagesUser/userinfo/userinfo',true)">
					<u-icon name="edit-pen" color="#ffffff" size="28"></u-icon>
					<text style="margin-left: 10rpx;">编辑</text>
				</view>
			</view>
			<!-- <u-grid :col="3" :border="false">
				<u-grid-item>
					<text>22</text>
					<view class="grid-text">发布</view>
				</u-grid-item>
				<u-grid-item>
					<text>22</text>
					<view class="grid-text">收藏</view>
				</u-grid-item>
				<u-grid-item>
					<text>22</text>
					<view class="grid-text">积分</view>
				</u-grid-item>
			</u-grid> -->
		</view>
		<view class="menu">
			<text class="menu-title">我的功能</text>
			<u-grid :col="4" :border="false">
				<u-grid-item @click="navTo('/pagesUser/push/push',true)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu12.png"></u-image>
						<view class="grid-text">我的发布</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/resume/resume',true)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu13.png"></u-image>
						<view class="grid-text">我的简历</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pages/shop/orderList?state=-1',true)">
                					<view class="gird">
                						<u-image width="80rpx" height="80rpx" src="@/static/images/menu13.png"></u-image>
                						<view class="grid-text">商城订单</view>
                					</view>
                				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/collect/collect',true)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu14.png"></u-image>
						<view class="grid-text">我的收藏</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesFind/store_center/store_center',true)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu15.png"></u-image>
						<view class="grid-text">我的店铺</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="playVideo">
                					<view class="gird">
                						<u-image width="80rpx" height="80rpx" src="@/static/images/menu15.png"></u-image>
                						<view class="grid-text">支持作者</view>
                					</view>
                				</u-grid-item>
				<!-- <u-grid-item @click="navTo('/pagesUser/msg/msg')">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu1.png"></u-image>
						<view class="grid-text">我的消息</view>
					</view>
				</u-grid-item> -->
			</u-grid>
		</view>
		<view class="menu">
			<text class="menu-title">工具与服务</text>
			<u-grid :col="4" :border="false">
				<u-grid-item v-if="opentop" @click="navTo('/pagesUser/vip/vip',true)">
					<u-image width="80rpx" height="80rpx" src="@/static/images/vip.png"></u-image>
					<view class="grid-text">我的会员</view>
				</u-grid-item>
				<u-grid-item>
					<!--#ifdef MP-WEIXIN-->
					<button class="concat" hover-class='none' open-type="contact">
						<u-image style="margin-bottom: -15rpx;" width="80rpx" height="80rpx"
							src="@/static/images/menu16.png"></u-image>
						<view style="margin-bottom: -15rpx;" class="grid-text">联系客服</view>
					</button>
					<!--#endif-->
					<!--#ifndef MP-WEIXIN-->
					<view class="gird" @click="callContact">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu16.png"></u-image>
						<view class="grid-text">联系客服</view>
					</view>
					<!--#endif-->
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/help/help',false)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu17.png"></u-image>
						<view class="grid-text">帮助中心</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/feedback/feedback',true)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu18.png"></u-image>
						<view class="grid-text">意见反馈</view>
					</view>
				</u-grid-item>
				<u-grid-item>
					<!--#ifdef MP-WEIXIN-->
					<button class="concat" hover-class='none' open-type="share">
						<u-image style="margin-bottom: -15rpx;" width="80rpx" height="80rpx"
							src="@/static/images/menu19.png"></u-image>
						<view style="margin-bottom: -15rpx;" class="grid-text">邀请好友</view>
					</button>
					<!--#endif-->
					<!--#ifndef MP-WEIXIN-->
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu19.png"></u-image>
						<view class="grid-text">邀请好友</view>
					</view>
					<!--#endif-->
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/setting/setting',false)">
					<view class="gird">
						<u-image width="80rpx" height="80rpx" src="@/static/images/menu20.png"></u-image>
						<view class="grid-text">系统设置</view>
					</view>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex'
	import {
		APP_MOBILE,
		APP_NAME
	} from '../../env.js'
	var videoAd = null
	export default {
		data() {
			return {
				userVip: {

					name: "普通会员"
				},
				opentop:false,
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				isLogin: state => state.user.isLogin,
			})
		},
		onLoad() {
			this.getVerify()
		},
		mounted() {


        			// 在页面onLoad回调事件中创建激励视频广告实例
        			if (wx.createRewardedVideoAd) {
        			  videoAd = wx.createRewardedVideoAd({
        			    adUnitId: 'adunit-423ae5f74586925b'
        			  })
        			  videoAd.onLoad(() => {})
        			  videoAd.onError((err) => {})
        			  videoAd.onClose((res) => {})
        			}

        		},
		onShow() {
			if (this.isLogin) {
				this.$u.get('/home/level/getCateFreeNum', {
type:1
				}).then(res => {
					this.userVip = res
				})
			}
		},
		onShareAppMessage() {
			return {
				title: APP_NAME,
				path: '/pages/index/index'
			}
		},
		methods: {
		playVideo(){
        				videoAd.show()
        				.catch(() => {
        				    videoAd.load()
        				    .then(() => videoAd.show())
        				    .catch(err => {
        				      console.log('激励视频 广告显示失败')
        				    })
        				})
        			},
			getVerify() {
				this.$u.get('/tc/verifyToken', {}).then(res => {
					this.opentop = res.opentop;
				})
			},
			navTo(path, toLogin) {
				if (toLogin) {
					if (this.isLogin) {
						this.$u.route(path)
					} else {
						this.$u.route('/pages/login/login')
					}

				} else {
					this.$u.route(path)
				}
			},
			callContact() {
				uni.makePhoneCall({
					phoneNumber: APP_MOBILE
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 好玩动态
    	.dong {
    		z-index: 9999;
    		position: fixed;
    		top: -40px;
    		right: -80px;
    		transform: scale(0.24);
    		-webkit-transform: scale(0.24);
    		-moz-transform: scale(0.24);

    	}

    	.monster {
    		transform: rotate(-50deg);
    		-ms-transform: rotate(-50deg);
    		/* IE 9 */
    		-moz-transform: rotate(-50deg);
    		/* Firefox */
    		-webkit-transform: rotate(-50deg);
    		/* Safari 和 Chrome */
    		-o-transform: rotate(-50deg);
    		/* Opera */
    		display: flex;
    		justify-content: center;
    		position: relative;
    		width: 170px;
    		height: 400px;
    		border-top-left-radius: 200px;
    		border-top-right-radius: 200px;
    		background-color: #3C47D7;
    		box-shadow: 20px 20px 60px #4650E5;
    	}

    	.monster__face {
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		flex-direction: column;
    		position: absolute;
    		top: 14%;
    		width: 75%;
    		height: 160px;
    	}

    	.monster__noses {
    		top: 50%;
    		display: flex;
    		justify-content: space-between;
    		width: 28%;
    		height: auto;
    		margin-bottom: 10px;
    	}

    	.monster__nose {
    		width: 8px;
    		height: 12px;
    		border-radius: 20px;
    		background: rgba(0, 0, 0, 0.5);
    		box-shadow: 4px 8px 5px rgba(0, 0, 0, 0.1);
    	}

    	.monster__mouth {
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		position: relative;
    		width: 100%;
    		height: 0%;
    		overflow: hidden;
    		border: 25px solid #FFC333;
    		border-radius: 100px;
    		background-color: #810332;
    		animation: mouth 1.75s infinite;
    		box-shadow: 4px 8px 5px rgba(0, 0, 0, 0.2);
    		box-sizing: border-box;
    	}

    	.monster__mouth::before {
    		content: '';
    		position: absolute;
    		width: 150px;
    		height: 80px;
    		border-radius: 100px;
    		background-color: #400018;
    	}

    	.monster__mouth::after {
    		content: '';
    		position: absolute;
    		bottom: -80px;
    		width: 160px;
    		height: 80px;
    		border-top-left-radius: 50%;
    		border-top-right-radius: 50%;
    		background-color: #DC1B50;
    		animation: tongue 1.75s infinite;
    	}

    	.monster__top {
    		position: absolute;
    		top: -30px;
    		width: 170px;
    		height: 30px;
    		border-bottom-left-radius: 10px;
    		border-bottom-right-radius: 10px;
    		background-color: #ffffff;
    		z-index: 100;
    		animation: t 1.75s infinite;
    	}

    	.monster__bottom {
    		position: absolute;
    		bottom: 0;
    		width: 100px;
    		height: 30px;
    		border-top-left-radius: 10px;
    		border-top-right-radius: 10px;
    		background-color: #ffffff;
    		z-index: 100;
    		animation: b 1.75s infinite;
    	}

	.user {
		background-color: white;
		margin: 20rpx;
		border-radius: 20rpx;
		padding: 20rpx;

		.user-top {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;

			.userinfo {
				display: flex;
				flex-direction: row;
				align-items: center;

				.info {
					margin-left: 20rpx;
					color: #333333;
					font-weight: 600;
					font-size: 35rpx;
					word-break: break-all;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					margin-right: 20rpx;

					.vip {
						display: flex;
						flex-direction: row;
						align-items: center;
						font-size: 24rpx;
						margin-top: 15rpx;

						.viptext {
							margin-left: 10rpx;
							color: #333333;
							font-weight: normal;
						}
					}
				}
			}

			.sigin {
				background-color: #f44c01;
				margin-right: -20rpx;
				border-top-left-radius: 30rpx;
				border-bottom-left-radius: 30rpx;
				color: white;
				height: 50rpx;
				width: 150rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
			}
		}
	}

	.menu {
		margin: 20rpx;
		background-color: white;
		padding: 20rpx;
		border-radius: 20rpx;

		.menu-title {
			font-size: 32rpx;
			color: #666666;
		}
	}

	.gird {
		height: 120rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #333333;
	}

	.concat {
		font-size: 28rpx;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0;
		margin: 0;
		height: 120rpx;
		overflow: hidden;
		color: #333333;
	}

	.concat::after {
		border: none;
	}
</style>
